/*
* File:			stack.h
* Author:		Akira
* Date:			2023-11-15
* Description:	堆栈的链式存储实现
* Version: 		1.0.0
* Modify: 		None.
*/

#ifndef __STACK_H__
#define __STACK_H__

#include <stdlib.h>
#include <stdbool.h>
#include <malloc.h>

//1：带头节点；0：不带头节点
#define STACK_WITH_HEAD_NODE 	1

// 堆栈的链式存储实现(带头结点和不带头结点)

typedef int ElemType;

typedef struct LinkNode {
	ElemType data;			//数据域
	struct LinkNode* next;	//指针域
} LinkNode;

typedef struct {
	LinkNode* top;
	int length;
} LinkStack;

extern bool InitStack(LinkStack *s);
extern bool StackEmpty(LinkStack *s);
extern bool PushStack(LinkStack *s, ElemType x);
extern bool PopStack(LinkStack *s, ElemType* x);
extern bool GetTop(LinkStack *s, ElemType* x);
extern int LengthStack(LinkStack *s);

#endif /* __STACK_H__ */
